using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class UIBag : MonoBehaviour
{
    public GameObject bagItem;
    public Transform content;
    private List<UIBagItem> bagItems;
    int currentIndex = -1;
    // Start is called before the first frame update
    void Start()
    {
        DataManager.Instance.Load();
        bagItems = new List<UIBagItem>();
        foreach(var kv in content.GetComponentsInChildren<UIBagItem>())
        {
            bagItems.Add(kv);
        }
    }

    // Update is called once per frame
    void Update()
    {
        
    }
    public void Select(int index)
    {
        if (index != currentIndex)
        {
            foreach (var item in bagItems)
            {
                if (item.id == index)
                {
                    item.transform.Find("ClickPanel").gameObject.SetActive(true);
                }
                else
                {
                    item.transform.Find("ClickPanel").gameObject.SetActive(false);
                }
            }
        }
    }
}
